package com.smartmedical.system.patient.service.lmpl;


import com.baomidou.dynamic.datasource.annotation.DS;
import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.system.api.domain.PatientUsers;

import com.smartmedical.system.patient.domain.dto.PatientIserArchivesDto;
import com.smartmedical.system.patient.domain.dto.PatientTaskdto;
import com.smartmedical.system.patient.domain.dto.PatientUserIdCardDto;
import com.smartmedical.system.patient.domain.entity.*;
import com.smartmedical.system.patient.domain.vo.*;
import com.smartmedical.system.patient.mapper.PatientUserMapper;
import com.smartmedical.system.patient.service.PatientUserService;


import com.smartmedical.system.patient.util.EmailUtil;
import com.smartmedical.system.patient.util.FastUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.util.*;

/**
 * @BelongsProject: smart-medical
 * @BelongsPackage: com.smartmedical.service.lmpl
 * @ClassName: UserServiceLMPL
 * @Author: zyn
 * @CreateTime: 2024-01-08  16:52
 * @Description: TODO
 */
@Service
@DS(value = "slave")
@Log4j2
public class PatientUserServiceLMPL implements PatientUserService{


    @Autowired
    private PatientUserMapper patientUserMapper;


    @Autowired
    RedisTemplate<String,String> redisTemplate;

    @Autowired
    private FastUtil fastUtil;
    @Autowired
    private EmailUtil emailUtil;



    /**
     * 登录函数，用于通过email获取用户信息
     *
     * @param email 用户email
     * @return 用户信息
     */
    @Override
    public PatientUsers login(String email) {

        // 调用patientUserMapper的login方法，传入email和pwd参数，返回用户信息
        PatientUsers user = patientUserMapper.login(email);

        // 如果返回的用户信息为空
        if (user == null) {
//             记录错误日志，内容为“用户不存在”
           log.error("用户不存在");
        }

        // 返回用户信息
        return user;
    }



    /**
     * 发送电子邮件验证码
     *
     * @param email 邮箱地址
     * @return 返回一个HealthR对象，包含EmailCodeVo对象和字符串信息
     */
    @Override
    public HealthR sendOutEmailCode(String email) {

      //利用随机数生成验证码
        Random random = new Random();
        String code = "";
        for (int i = 0; i < 4; i++) {
            code +=random.nextInt(10);
        }
        System.out.println("本次获取的验证码为：" + code);
        EmailCodeVo emailCodeVo = new EmailCodeVo();
       //存入缓存
        emailUtil.saveCode(code,email);
       //发送邮件
        emailUtil.sendCode(code,email);

//        emailCodeVo.setEmail(email);
//        emailCodeVo.setCode(emailCodeVo.getCode());
      //  redisTemplate.opsForValue().set(email,code);


        return HealthR.ok("00000","发送成功");
    }

    /**
     * 注册用户
     *
     * @param email 邮箱
     * @param code 验证码
     * @param pwd1 密码
     * @param pwd2 确认密码
     * @param invitationCode 邀请码
     * @return 注册结果
     */
    @Override
    public HealthR registerUser(String email, String code, String pwd1, String pwd2, String invitationCode) {


        String code1 = emailUtil.getCode(email);
        if(!code1.equals(code)){
            return HealthR.fail("验证码错误");
        }
//        if (pwd1.equals(pwd2)) {
//            return HealthR.fail("两次密码不一致");
//        }


        if (email == null || code == null || pwd1 == null || pwd2 == null) {
            return HealthR.fail("参数不能为空");
        }
        PatientUserEntity patientUserEntity = new PatientUserEntity();
        patientUserEntity.setEmail(email);
        patientUserEntity.setPwd(pwd1);
        patientUserEntity.setPwd(pwd2);
        patientUserEntity.setInvitationCode(invitationCode);

        patientUserMapper.insert(patientUserEntity);
        return HealthR.ok("注册成功");
    }

    /**
     * 根据用户ID获取用户信息
     *
     * @param id 用户ID
     * @return 用户信息
     */
    @Override
    public UserInfoByIdVo UserInfoById(Long id) {
        if (id == null) {
            log.error("id为空");
        }


        return patientUserMapper.userInfoById(id);
    }

    /**
     * 完善用户信息
     *
     * @param age 年龄
     * @param height 身高
     * @param weight 体重
     * @param id 用户ID
     */
    @Override
    public void perfectUserInfo(Integer age, Integer height, Integer weight, Long id) {
        if (age == null || height == null || weight == null) {
            log.error("参数为空");
        }

        patientUserMapper.perfectUserInfo(age,height,weight,id);
    }

    /**
     * 上传头像图片
     *
     * @param image 要上传的文件
     * @return HealthR对象，包含上传结果的状态和信息
     * @throws RuntimeException 上传异常
     */
    @Override
    public  HealthR uploadHeadPic(MultipartFile image) {

        String upload="";
        try {
            // 调用fastUtil类的upload方法上传文件，并返回上传的路径
            upload = fastUtil.upload(image);
            if (upload.equals("")){
                // 如果上传路径为空，则返回上传失败的结果
                return HealthR.fail("上传失败");
            }
        } catch (Exception e) {
            // 捕获异常，抛出运行时异常，表示上传异常
            throw new RuntimeException("上传异常");
        }


        // 返回上传成功的HealthR对象，包含上传结果的链接和状态信息
        return    HealthR.ok("http://152.136.54.230:8888/"+upload,"上传成功");
    }


    /**
     * 将患者档案添加到数据库中
     *
     * @param patientIserArchivesDto 患者档案信息
     */
    @Override
    public void addUserArchives(PatientIserArchivesDto patientIserArchivesDto) {

        // 如果参数为空，则记录错误日志
        if (patientIserArchivesDto == null) {
            log.error("参数为空");
        }
        // 断言参数不为空
        assert patientIserArchivesDto != null;

        // 设置治疗开始时间为当前时间
        patientIserArchivesDto.setTreatmentStartTime(new Date());
        // 设置治疗结束时间为当前时间
        patientIserArchivesDto.setTreatmentEndTime(new Date());


        // 调用mapper的addUserArchives方法，将患者档案添加到数据库中
        patientUserMapper.addUserArchives(patientIserArchivesDto);
    }

    @Override
    public HealthR uploadArchivesPicture(String[] picture, Long archivesId) {

        if (picture == null || picture.length == 0) {
            return HealthR.fail("图片为空");
        }

        String pictureString = String.join(",", picture); // 使用逗号分隔图片路径

        patientUserMapper.uploadArchivesPicture(pictureString,archivesId);
        return HealthR.ok();
    }

    @Override
    public HealthR<PatientIserArchivesVo> findUserArchives(Long userId) {

        // 查询用户档案信息
        PatientIserArchivesEntity userArchives = patientUserMapper.findUserArchives(userId);

        // 创建患者档案信息对象
        PatientIserArchivesVo patientIserArchivesVo = new PatientIserArchivesVo();

        // 设置用户ID
        patientIserArchivesVo.setUserId(userId);

        // 设置档案ID
        patientIserArchivesVo.setId(userArchives.getId());

        // 设置主要疾病
        patientIserArchivesVo.setDiseaseMain(userArchives.getDiseaseMain());

        // 设置当前疾病
        patientIserArchivesVo.setDiseaseNow(userArchives.getDiseaseNow());

        // 设置以前疾病
        patientIserArchivesVo.setDiseaseBefore(userArchives.getDiseaseBefore());

        // 设置最近治疗医院
        patientIserArchivesVo.setTreatmentHospitalRecent(userArchives.getTreatmentHospitalRecent());

        // 设置治疗过程
        patientIserArchivesVo.setTreatmentProcess(userArchives.getTreatmentProcess());

        // 设置治疗开始时间
        patientIserArchivesVo.setTreatmentStartTime(userArchives.getTreatmentStartTime());

        // 设置治疗结束时间
        patientIserArchivesVo.setTreatmentEndTime(userArchives.getTreatmentEndTime());

        // 设置图片链接
        patientIserArchivesVo.setPicture(userArchives.getPicture());

        // 返回健康状态和患者档案信息对象
        return HealthR.ok(patientIserArchivesVo);
    }


    @Override
    public void addSign(Long userId) {
        // 创建一个PatientUserConsumptionRecordEntity对象
        PatientUserConsumptionRecordEntity patientUserConsumptionRecordEntity = new PatientUserConsumptionRecordEntity();
        // 设置userId属性
        patientUserConsumptionRecordEntity.setUserId(userId);
        // 设置type属性为1
        patientUserConsumptionRecordEntity.setType(1);
        // 设置创建时间为当前时间
        patientUserConsumptionRecordEntity.setCreateTime(new Date());
        // 调用patientUserMapper的addSign方法，将对象添加到数据库中
        patientUserMapper.addSign(patientUserConsumptionRecordEntity);
    }

    @Override
    public HealthR<List<PatientUserConsumptionRecordEntity>> whetherSignToday(Long userId) {

        // 查询用户今日是否已签
        List<PatientUserConsumptionRecordEntity> patientUserConsumptionRecordEntities = patientUserMapper.whetherSignToday(userId);

        // 如果查询结果为空或者查询结果的大小为0，则抛出异常
        if (patientUserConsumptionRecordEntities == null || patientUserConsumptionRecordEntities.size() == 0) {
            throw new RuntimeException("今日已签");
        }

        // 返回查询结果m
        return HealthR.ok(patientUserConsumptionRecordEntities);
    }

    @Override
    public HealthR<List<PatientUserConsumptionRecordEntity>> whetherSignTodays(Long userId) {
        List<PatientUserConsumptionRecordEntity> patientUserConsumptionRecordEntities = patientUserMapper.whetherSignTodays(userId);
        if (patientUserConsumptionRecordEntities == null || patientUserConsumptionRecordEntities.size() == 0) {
            throw new RuntimeException("今日已签");
        }

        return HealthR.ok(patientUserConsumptionRecordEntities);
    }

    @Override
    public void updateUserInfo(Integer sex, Long userId) {

        if (sex == 0 || sex == 1) {
            throw new RuntimeException("性别错误");
        }

        patientUserMapper.updateUserInfo(sex,userId);



    }

    @Override
    public void updateUserNickName(String nickName, Long userId) {
        if (nickName == null || nickName.length() > 10) {
            throw new RuntimeException("昵称错误");
        }
        patientUserMapper.updateUserNickName(nickName,userId);
    }

    @Override
    public void makeInvitationCode(Long userId) {

        if (userId == null) {
            throw new RuntimeException("用户ID错误");
        }
        PatientUserEntity patientUserEntity = new PatientUserEntity();
        String s = UUID.randomUUID().toString().replaceAll("-", "");
        patientUserEntity.setId(userId);
        patientUserEntity.setInvitationCode(s);

        patientUserMapper.makeInvitationCode(patientUserEntity);
    }

    @Override
    public HealthR<List<PatientUserEntity>> findUserInvitationCode(Long userId) {


        if (userId == null) {
            throw new RuntimeException("用户ID错误");
        }
        List<PatientUserEntity> patientUsers = patientUserMapper.findUserInvitationCode(userId);


        return HealthR.ok(patientUsers);
    }

    @Override
    public void updateUserPwd(String oldPwd, String newPwd, Long userId) {
        if (oldPwd == null || newPwd == null) {
            throw new RuntimeException("密码错误");
        }

        PatientUserEntity patientUserEntity = new PatientUserEntity();
        patientUserEntity.setId(userId);
        patientUserEntity.setPwd(oldPwd);
        patientUserEntity.setPwd(newPwd);
        patientUserMapper.updateUserPwd(patientUserEntity);

    }

    @Override
    public void addPushToken(String token, Long userId) {

//        Optional<PatientUserEntity> optionalUser = userRepository.findById((long) userId);








    }

    @Override
    public void doTask(Integer taskId, Long userId) {
        if (taskId == null || userId == null) {
            throw new RuntimeException("参数错误");
        }

        PatientTaskdto patientTaskdto = new PatientTaskdto();
        patientTaskdto.setId(taskId);
        patientTaskdto.setReward(1);
        patientTaskdto.setTaskType(1);

        patientUserMapper.doTask(patientTaskdto);


    }

    @Override
    public HealthR<UserTaskRecordVo> findUserTaskList(Long userId) {
        if (userId == null) {
            throw new RuntimeException("用户ID错误");
        }


        return HealthR.ok(patientUserMapper.findUserTaskList(userId));
    }

    @Override
    public void receiveReward(Integer taskId, Long userId) {


        if (taskId == null || userId == null) {
            throw new RuntimeException("参数错误");
        }

        UserTaskRecordEntity userTaskRecordEntitys= patientUserMapper.receiveReward(taskId,userId);
        if (userTaskRecordEntitys.getStatus() == 2) {
            throw new RuntimeException("今日任务已领取");
        }

        PatientTaskdto patientTaskdto = new PatientTaskdto();
        patientTaskdto.setId(taskId);
        patientTaskdto.setTaskName("奖励");
        patientTaskdto.setReward(1);
        patientTaskdto.setTaskType(1);

        patientUserMapper.doTask(patientTaskdto);
        patientUserMapper.upd(patientTaskdto.getId());


    }

    @Override
    public void updateArchives(PatientIserArchivesDto archives) {
        if (archives == null ) {
            throw new RuntimeException("参数错误");
        }
        patientUserMapper.updateArchives(archives);
    }

    @Override
    public void deleteArchives(Integer archivesId) {
        if (archivesId == null) {
            throw new RuntimeException("参数错误");
        }
        patientUserMapper.deleteArchives(archivesId);
    }

    @Override
    public  HealthR addInfoCollection(Integer infoId) {
        if (infoId == null) {
            throw new RuntimeException("参数错误");
        }

         List<PatientInfoCountEntity>  patientInfoCountEntities=patientUserMapper.findInfoId();
        patientInfoCountEntities.forEach(patientInfoCountEntity -> {
            if (!patientInfoCountEntity.getInfoId().equals(infoId)) {
                patientInfoCountEntity.setCollectionNum(1);
                patientInfoCountEntity.setShareNum(1);
                patientInfoCountEntity.setCreateTime(new Date());
                patientUserMapper.addcollection(patientInfoCountEntity);
            }
        }) ;
       List<InformationEntity> informationEntities = patientUserMapper.findInfoCollections();
        informationEntities.forEach(informationEntity -> {
            if (informationEntity.getId().equals(infoId)) {
                informationEntity.setWhetherCollection(1);
                patientUserMapper.updinformationEntity(informationEntity.getId(),informationEntity.getWhetherCollection());
            }
        });


       return HealthR.ok();

    }

    @Override
    public HealthR<List<PatientInfoVo>> findInfoCollections() {

        List<PatientInfoVo> patientInfoVos = patientUserMapper.selectInfoCollection();

        return HealthR.ok(patientInfoVos);
    }

    @Override
    public void cancelInfoCollection(Integer infoId) {
        if (infoId == null) {
            throw new RuntimeException("参数错误");
        }

        patientUserMapper.updinformationEntitys(infoId);


    }

    @Override
    public HealthR<List<PatientVideoVo>> findVideoCollectionList(Integer page, Integer count) {

        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientVideoVo> videoCollectionList = patientUserMapper.findVideoCollectionList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollections();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientVideoVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;

    }

    @Override
    public void cancelVideoCollection(Integer videoId) {
        if (videoId == null) {
            throw new RuntimeException("参数错误");
        }

        patientUserMapper.cancelVideoCollection(videoId);




    }

    @Override
    public HealthR<List<PatientUserDoctorVo>> findUserDoctorFollowList(@RequestParam Integer page, @RequestParam  Integer count) {

        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientUserDoctorVo> videoCollectionList = patientUserMapper.findUserDoctorFollowList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollectios();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientUserDoctorVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
         healthR.setTotalRecords(totalRecords);


        return healthR;

    }

    @Override
    public HealthR<List<PatientUserVideoVo>> findUserVideoBuyList(Integer page, Integer count) {
        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientUserVideoVo> videoCollectionList = patientUserMapper.findVideoCollectionLists(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollectio();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientUserVideoVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public void deleteVideoBuy(Integer videoId) {
        if (videoId == null) {
            throw new RuntimeException("参数错误");
        }
        patientUserMapper.deleteVideoBuy(videoId);
    }

    @Override
    public HealthR<List<ConsumptionRecordVo>> findUserConsumptionRecordList(Integer page, Integer count) {
        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<ConsumptionRecordVo> videoCollectionList = patientUserMapper.findUserConsumptionRecordList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollecti();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<ConsumptionRecordVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public HealthR<PatientUserWalletEntity> findUserWallet(Long userId) {
        if (userId == null) {
            throw new RuntimeException("参数错误");
        }
        PatientUserWalletEntity patientUserWallet = patientUserMapper.findUserWallet(userId);
        return HealthR.ok(patientUserWallet);
    }

    @Override
    public HealthR checkCode(String email, String code) {

        if (email == null || code == null) {
            throw new RuntimeException("参数错误");
        }

        PatientUserEntity patientUserEntity = patientUserMapper.checkEmail(email);
         if (!patientUserEntity.getEmail().equals(email)) {
            return HealthR.fail("邮箱不存在");
        }
        String code1 = emailUtil.getCode(email);
        if(!code1.equals(code)){
            return HealthR.fail("验证码错误");
        }


        return HealthR.ok("验证错误");
    }

    @Override
    public void resetUserPwd(String email, String pwd1, String pwd2) {
        if (email == null || pwd1 == null || pwd2 == null) {
            throw new RuntimeException("参数错误");
        }
        List<PatientUserEntity> patientUserEntities = patientUserMapper.selectByEmail();
        patientUserEntities.forEach(patientUserEntity -> {
            if (patientUserEntity.getEmail().equals(email)) {

                patientUserMapper.upds(email, pwd1, pwd2);
            }
        });





    }

    @Override
    public HealthR<List<PatientNoticeVo>> findSystemNoticeList(Integer page, Integer count) {


        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientNoticeVo> videoCollectionList = patientUserMapper.findSystemNoticeList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollect();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientNoticeVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public HealthR<List<PatientInquiryNoticeVo>> findInquiryNoticeList(Integer page, Integer count) {



        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientInquiryNoticeVo> videoCollectionList = patientUserMapper.findInquiryNoticeList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoCollec();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientInquiryNoticeVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public HealthR<List<CurrencyNoticeVo>> findHealthyCurrencyNoticeList(Integer page, Integer count) {
        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<CurrencyNoticeVo> videoCollectionList = patientUserMapper.findCurrencyNoticeList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoColle();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<CurrencyNoticeVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public void bindUserBankCard(String bankCardNumber, String bankName, String bankCardType) {

        List<PatientUserBankCardEntity> patientUserEntities = patientUserMapper.selectBankCard();
        patientUserEntities.forEach(patientUserEntity -> {
            if (patientUserEntity.getBankCardNumber().equals(bankCardNumber)) {

                patientUserMapper.updateBankCard(patientUserEntity);
            }
        });

        patientUserMapper.addbankCard(bankCardNumber, bankName, bankCardType);
    }

    @Override
    public HealthR<PatientBankCardInfoVo> findUserBankCardByUserId(Long userId) {
        if (userId == null) {
            throw new RuntimeException("参数错误");
        }

        PatientBankCardInfoVo  patientBankCardInfoVo= patientUserMapper.bindUserBankCard(userId);

        return HealthR.ok(patientBankCardInfoVo);
    }

    @Override
    public void bindUserIdCard(PatientUserIdCardDto patientUserIdCardDto) {


        if (patientUserIdCardDto == null) {
            throw new RuntimeException("参数错误");
        }
        patientUserMapper.addbindUserBankCard(patientUserIdCardDto);
    }

    @Override
    public HealthR<PatientUserIdCardVo> findUserIdCard(Long userId) {
        if (userId == null) {
            throw new RuntimeException("参数错误");
        }
        PatientUserIdCardVo patientUserIdCardVo=patientUserMapper.findUserIdCard(userId);
        return HealthR.ok(patientUserIdCardVo);
    }

    @Override
    public HealthR<List<PatientUserDrawRecordVo>> findUserDrawRecordList(Integer page, Integer count) {
        // 计算分页偏移量
        int offset = (page - 1) * count;

        // 调用Repository或数据库操作，获取分页数据
        List<PatientUserDrawRecordVo> videoCollectionList = patientUserMapper.findUserDrawRecordList(offset, count);

        // 获取总记录数（用于前端分页）
        int totalRecords = patientUserMapper.countVideoColl();

        // 构建HealthR对象，包含查询结果和总记录数
        HealthR<List<PatientUserDrawRecordVo>> healthR = new HealthR<>();
        healthR.setResult(videoCollectionList);
        healthR.setTotalRecords(totalRecords);


        return healthR;
    }

    @Override
    public void drawCash(Integer money, Long userId) {

        //提现
        if (money <= 0) {
            throw new RuntimeException("无法提现");
        }
        if (money > 10000) {
            throw new RuntimeException("提现金额不能超过10000");
        }
        PatientUserDrawRecordEntity patientUserDrawRecordEntity=patientUserMapper.findUserDrawRecord(userId);
        if(patientUserDrawRecordEntity.getMoney()==money){
            patientUserDrawRecordEntity.setMoney(patientUserDrawRecordEntity.getMoney()-money);
            patientUserMapper.updStatus(patientUserDrawRecordEntity.getId(),patientUserDrawRecordEntity.getMoney());
        }
    }

    @Override
    public void watchInfoRewards(Integer infoId, Long userId) {
        informationWatchRewardRecord patientInfoCountEntity=patientUserMapper.fingwindInfoCollection(userId);

        if(patientInfoCountEntity.getInfoId()==infoId){
            if (patientInfoCountEntity.getWatchTimes()==10) {
                throw new RuntimeException("获得奖励成功");
            }
        }

    }

    @Override
    public List<PatientSystemNoticeEntity> findUserNoticeReadNum() {


       return patientUserMapper.findUserNoticeReadNum();

    }

    @Override
    public void modifyAllStatus(Long userId) {

        patientUserMapper.modifyAllStatus(userId);
    }

    @Override
    public HealthR<String> userHealthTest() {
        String url = "https://www.wjx.cn/jq/33939807.aspx";

        return HealthR.ok(url, "查询成功");
    }


}


